import { createRouter, createWebHashHistory } from 'vue-router'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

const routes = [
  {
    path: '/',
    title: '首页',
    name: 'home',
    component: () => import('../views/index.vue')
  },
  {
    path: '/about',
    title: '关于',
    name: 'about',
    component: () => import('../views/AboutView.vue')
  },
  {
    path: '/login',
    title: 'login',
    name: 'login',
    component: () => import('../views/Login.vue')
  },
  {
    path: '/layout',
    title: 'layout',
    name: 'layout',
    component: () => import('../views/Layout.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  NProgress.start()
  next()
})
router.afterEach((to, from) => {
  NProgress.done()
  NProgress.remove()
})
export default router
